
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="./lib/gc.spread.sheets.13.0.0.css">
  <link rel="stylesheet" href="../assets/css/style.css">
  <link rel="stylesheet" href="../build/common/base.css">


  <link rel="stylesheet" href="../build/form/form.css">
  <link rel="stylesheet" href="../build/form/page.css">
  <link rel="stylesheet" href="../build/form/preview.css">
  <link rel="stylesheet" href="../assets/js/plugins/icheck/skins/all.css">


  <link rel="stylesheet" href="../assets/js/common/element/index.css">
  <script type="text/javascript" src="../build/common/base.js"></script>
  <script type="text/javascript" src="../build/common/vueEdit.js"></script>
  <style>
    * {
      margin: 0;
      padding: 0
    }

    li {
      list-style: none
    }

    img {
      vertical-align: top;
      border: none
    }

    .rev_file {
      width: 53px;
      height: 33px;
      position: relative;
    }

    .btn_rev {
      width: 100%;
      height: 100%;
      position: absolute;
    }

    .fun_box {
      display: flex;
      margin: 15px;

    }

    .my_btns {
      margin-left: 15px;
      width: 53px;
      height: 33px;
    }

    .title {
      border-bottom: 1px #ccc dashed;
      text-align: center;
      font-size: 20px;
      padding-bottom: 20px;
      padding-top: 20px;
      margin-bottom: 20px;
    }

    .execl_box {
      margin: 0 auto;
      padding: 20px;
      margin-bottom: 60px;
    }

    .btn_box {
      display: flex;
      margin-bottom: 20px;
    }

    .btn_file_box {
      position: relative;
      margin-right: 5px;
    }

    .file_up {
      position: absolute;
      top: 0;
    }

    #importUrl {
      z-index: 999;
      opacity: 0;
    }

    .my_name {
      max-width: 230px;
      margin-bottom: 20px;
      margin-left: 8px;
      border-radius: 5px;
    }

    .tab_th tbody th {
      text-align: right;
    }

    .my_table thead th,
    .my_table td {
      /* white-space: nowrap; */
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* input[type=file] {
      display: none;
    } */
    .uplad_box input[type=file] {
      display: none;
    }

    .uplad_box {
      margin-bottom: 30px;
    }

    .no_data {
      width: 100%;
      padding: 8px;
      background-color: #f9f9f9;
      text-align: center;

    }

    #barcon {
      margin-top: 20px;
      margin-bottom: 20px;
      font-size: 16px;
    }

    /* #barcon a {
      
    } */
  </style>
</head>

<body>

  <div id="app" style="padding: 30px;">

    <!-- <div>
      <el-upload name="预算单" class="upload-demo" drag action="https://127.0.0.1:18084/project/upload" multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
      </el-upload>
    </div> -->
    <div style="width: 50%;">




    </div>
    <div>
      <table style=" margin: 0 auto; margin-bottom: 20px;" id="exampleTable"
        class="tab_th table table-striped table-bordered table_hover text-center mb60">
        <thead>
          <tr>
            <th colspan="3" style="text-align: center;">项目登记信息</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th>项目名称:</th>
            <td>{{surbeyObj.project_opportunity_name}}</td>
          </tr>
          <tr>
            <th>跟进人员名称:</th>
            <td>{{surbeyObj.project_manager_user_name}}</td>
          </tr>
          <tr>
            <th>登记日期:</th>
            <td>{{surbeyObj.pre_sale_project_year}}</td>
          </tr>
          <tr>
            <th>项目编号:</th>
            <td>{{surbeyObj.pre_sale_project_num}}</td>
          </tr>
        </tbody>
      </table>

    </div>
    <div style="display: flex;">
      <div style="width: 50%;">
        <div style="width: 100%;">
          <label style="width: 20%; text-align: center;">
            预算单名字:
          </label>
          <input disabled="disabled" style="width: 60%;" ref="must" class="form-control must" v-model="newData.newName"
            type="text" name="" id="">
        </div>
        <div style="width: 100%; display: flex; align-items: center; margin-top: 30px;margin-bottom: 30px;">
          <label style="width: 20%;text-align: center;">预算单版本号:</label>
          <!-- <input value="前期成本V1.0" disabled='disabled' style="width: 60%;" class="form-control" type="text" name=""
            id=""> -->
          <select style="width: 60%;" class="form-control" v-model="newData.version">
            <option v-for="item in seleOp" :key="item.value" :value="item.value">{{item.name}}</option>

          </select>
        </div>
      </div>
      <div style="width: 50%; display: flex; align-items: center; margin-top: 30px;margin-bottom: 30px;">
        <label style="width: 20%;text-align: center;">备注:</label>
        <textarea disabled="disabled" style="width: 60%;" v-model="newData.newBz" type="text"
          class="form-control ab-valid"></textarea>
      </div>
    </div>


    <div class="uplad_box">
      <el-button size="small" type="primary" @click="handEdit()">点击编辑</el-button>
    </div>
    <div style="overflow: auto;" class="mb60">
      <table style="margin-bottom: 0;" class="my_table table table-striped table-bordered table_hover text-center">
        <thead>
          <tr>
            <!-- <th>项目预算id</th> -->
            <th>任务编号</th>
            <th>任务名称</th>
            <th>报价单价</th>
            <th>保价金额</th>
            <th>备注</th>
            <th>数量</th>
            <th>单位</th>
            <th>人工工时(小时)</th>
            <th>人工费</th>
            <th>材料</th>
            <th>分包</th>
            <th>机具</th>
            <th>其他</th>
            <th>合计(元)</th>
            <th>合同额</th>
            <th>税额</th>
            <th>含税合计</th>
            <th>状态</th>
            <th>子项目</th>
          </tr>
        </thead>
        <tbody id="idData">
          <tr v-for="(item, index) in exList" :key="index">
            <!-- <td>{{item.projectID}}</td> -->
            <td>{{item.taskNumber}}</td>
            <td>{{item.taskName}}</td>
            <td>{{item.offerPrice}}</td>
            <td>{{item.offerMoney}}</td>
            <td>{{item.bz}}</td>
            <td>{{item.number}}</td>
            <td>{{item.dw}}</td>
            <td>{{item.hours}}</td>
            <td>{{item.Cost}}</td>
            <td>{{item.cl}}</td>
            <td>{{item.fb}}</td>
            <td>{{item.tool}}</td>
            <td>{{item.qt}}</td>
            <td>{{item.hj}}</td>
            <td>{{item.hte}}</td>
            <td>{{item.se}}</td>
            <td>{{item.hshj}}</td>
            <td>{{item.status==0?"草稿":(item.status==1?"未审核":"审核")}}</td>
            <td>{{item.zxm}}</td>
          </tr>
        </tbody>

      </table>
      <div v-if="exList.length==0" class="no_data">暂无数据</div>
      <table width="60%" align="right">
        <tr>
          <td>
            <div id="barcon" name="barcon"></div>
          </td>
        </tr>
      </table>
    </div>
    <div style="text-align: center;">
      <span @click="handSub()" class="btn btn-success fa fa-send mb30 mt30">保存</span>
      <span @click="handclos()" class="btn btn-success fa fa-times mb30 mt30">取消</span>
    </div>

  </div>






  <!-- <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> -->
  <script src="./lib/FileSaver.js"></script>
  <script src="./lib/gc.spread.sheets.all.13.0.0.min.js"></script>
  <script src="./lib/gc.spread.excelio.13.0.0.min.js"></script>
  <script src="./lib/gc.spread.sheets.migration.13.0.0.min.js"></script>
  <script src="./lib/gc.spread.sheets.resources.zh.13.0.0.min.js"></script>
  <script src="../assets/js/common/element/index.js"></script>
  <script>
    function goPage(pno, psize) {
      var itable = document.getElementById("idData");
      var num = itable.rows.length;//表格所有行数(所有记录数)
      console.log(num);
      var totalPage = 0;//总页数
      var pageSize = psize;//每页显示行数
      //总共分几页 
      if (num / pageSize > parseInt(num / pageSize)) {
        totalPage = parseInt(num / pageSize) + 1;
      } else {
        totalPage = parseInt(num / pageSize);
      }
      var currentPage = pno;//当前页数
      var startRow = (currentPage - 1) * pageSize + 1;//开始显示的行  31 
      var endRow = currentPage * pageSize;//结束显示的行   40
      endRow = (endRow > num) ? num : endRow; 40
      console.log(endRow);
      //遍历显示数据实现分页
      for (var i = 1; i < (num + 1); i++) {
        var irow = itable.rows[i - 1];
        if (i >= startRow && i <= endRow) {
          // irow.style.display = "block";
          $(irow).show()
        } else {
          $(irow).hide()
          // irow.style.display = "none";
        }
      }
      var pageEnd = document.getElementById("pageEnd");
      var tempStr = "共" + num + "条记录 分" + totalPage + "页 当前第" + currentPage + "页";
      if (currentPage > 1) {
        tempStr += "<a href=\"#\" onClick=\"goPage(" + (1) + "," + psize + ")\">首页</a>";
        tempStr += "<a href=\"#\" onClick=\"goPage(" + (currentPage - 1) + "," + psize + ")\"><上一页</a>"
      } else {
        tempStr += "首页";
        tempStr += "<上一页";
      }

      if (currentPage < totalPage) {
        tempStr += "<a href=\"#\" onClick=\"goPage(" + (currentPage + 1) + "," + psize + ")\">下一页></a>";
        tempStr += "<a href=\"#\" onClick=\"goPage(" + (totalPage) + "," + psize + ")\">尾页</a>";
      } else {
        tempStr += "下一页>";
        tempStr += "尾页";
      }

      document.getElementById("barcon").innerHTML = tempStr;

    }
    var vm = new Vue({
      el: "#app",
      data: {
        seleName: "",
        seleOp: [
          { name: "前期版本v1.0", value: "0" },
          { name: "讨论会成本v2.0", value: "1" },
          { name: "追加减版本v3.0", value: "2" }
        ],
        surbeyObj: "",
        id: "",
        rwid: "",
        fileList: [],
        exList: [],
        loading: Number,
        ids: "",
        bzTxt: "",
        url: "http://127.0.0.1:18084/project/uploadOne/",
        projectbudget: {
          code: "",
          registerTime: "",
          OnlyID: "",
          bz: "",
          projectName: "",
          userName: "",
          BudgetName: ""
        },
        yusuandanTxt: "",
        newData: {
          newID: "",
          newName: "",
          newBz: "",
          version: ""
        }
      },
      mounted() {
        this.rwid = location.search.replace("?", "")
        var name = decodeURIComponent(this.rwid)
        var nameList = name.split("&")
        this.newData.newID = nameList[0].split("id=")[1]
        this.newData.newName = nameList[1].split("name=")[1]
        this.newData.newBz = nameList[2].split("bz=")[1]
        this.newData.version = nameList[3].split("version=")[1]
        console.log("dsdsdsdsd", this.newData)
        var that = this
        var url = "http://127.0.0.1:18084/project/selectOne/76"
        var post = Vue.baseService.post(url);
        post.then(function (res) {
          console.log(res, "单个项目详细信息")
          that.surbeyObj = res
        }, function (status) {
          if (status == !0) {
            $.Toast.error('加载失败！' + status);
          }
        })

        var url = "http://127.0.0.1:18084/project/selectAll/" + this.newData.newID
        var post = Vue.baseService.get(url);
        post.then(function (res) {
          that.exList = res
          for (let i = 0; i < that.exList.length; i++) {
            that.exList[i].qt = parseInt(that.exList[i].qt) != parseInt(that.exList[i].qt) ? "" : parseInt(that.exList[i].qt).toFixed(2)
            that.exList[i].fb = parseInt(that.exList[i].fb) != parseInt(that.exList[i].fb) ? "" : parseInt(that.exList[i].fb).toFixed(2)
            that.exList[i].se = parseInt(that.exList[i].se) != parseInt(that.exList[i].se) ? "" : parseInt(that.exList[i].se).toFixed(2)
            that.exList[i].cl = parseInt(that.exList[i].cl) != parseInt(that.exList[i].cl) ? "" : parseInt(that.exList[i].cl).toFixed(2)
          }
          setTimeout("goPage(1, 10)", 200)
        }, function (status) {
          if (status == !0) {
            $.Toast.error('加载失败！' + status);
          }
        })
      },
      methods: {
        handSub: function () {
          var that = this
          var url = "http://127.0.0.1:18084/project/updateVersion/" + this.newData.newID + "/" + this.newData.version;
          console.log("提交信息", this.newData.newID, "===", this.newData.version)
          $.ajax({
            url: url,
            type: "post",
            // dataType: "json",
            traditional: true,
            async: false,
            data: { projectbudget: JSON.stringify(that.projectbudget) },
            success: function (res) {
              // console.log("成功了吗????????", res)
              // $.Toast.success("添加成功")
              $.Dialog.success("保存成功", function () {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
                parent.layer.close(index);
              });

            }
          })
        },

        handEdit() {

          var index = layer.open({
            type: 2,
            content: './editorData.html?' + this.newData.newID,
            // content: '../../form/formCustSql/view/formCustSqlView.html?code=项目ve清单-变更',
            area: ['320px', '195px'],
            maxmin: true
          });
          layer.full(index);
        },
        handclos() {
          var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
          parent.layer.close(index);
        }
      },
      watch: {
        yusuandanTxt: function (newValue) {

        }
      }
    })







  </script>
</body>

</html>